package demo.chain.exception;


import cn.hutool.core.exceptions.ValidateException;

/**
 * @author : feixiang.li
 * @since : 2025-09-17 17:31
 */
public class MinValidatorHandler implements ValidatorHandler {

    private final int min;
    private final String message;

    public MinValidatorHandler(int min, String message) {
        this.min = min;
        this.message = message;
    }

    @Override
    public void validate(Object obj, ValidatorContext validatorContext) {

        if (obj == null || ((Integer) obj) < min) {
            validatorContext.appendError(message);
        }
        validatorContext.doNext(obj);
    }
}
